﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MOD;
using DAL;

namespace BLL
{
    public class B_Users
    {
        private int iDataConn = DataBase.IN_S2;
        public DataTable SelectUserIdPassWord(Int64 iUserId,String sPassWord)
        {
            DataBase dDb = new DataBase();
            StringBuilder sCmdText = new StringBuilder();

            sCmdText.Append("Select * from Users ");
            sCmdText.Append("where UserId = @UserId  ");
            SqlParameter[] sSp = {
                                    new SqlParameter("@UserId",SqlDbType.BigInt)
                                 };
            sSp[0].Value = iUserId;
   
            return dDb.GetDataTable(sCmdText.ToString(), iDataConn, sSp);
        }
        public DataTable SelectUserNamePassWord(String sUserName, String sPassWord)
        {
            DataBase dDb = new DataBase();
            StringBuilder sCmdText = new StringBuilder();

            sCmdText.Append("Select * from Users ");
            sCmdText.Append("where UserName = @UserName ");
            SqlParameter[] sSp = {
                                    new SqlParameter("@UserName",SqlDbType.VarChar,50)
                                  
                                 };
            sSp[0].Value = sUserName;
    
            return dDb.GetDataTable(sCmdText.ToString(), iDataConn, sSp);
        }
        public DataTable SelectUserWeiboId(Int64 sWeiboId, Int64 iWeiboFlag)
        {
            DataBase dDb = new DataBase();
            StringBuilder sCmdText = new StringBuilder();

            sCmdText.Append("Select a.*,b.password from ad_info a ");
            sCmdText.Append("left join (select * from users) as b ");
            sCmdText.Append("on a.UserId = b.UserId ");
            
            sCmdText.Append("and a.WeiboId =@WeiboId");
            SqlParameter[] sSp = {
 
                                    new SqlParameter("@WeiboId",SqlDbType.Int)
                                 };
 
            sSp[0].Value = sWeiboId;

            return dDb.GetDataTable(sCmdText.ToString(), iDataConn, sSp);
        }
    }
}
